<template>
  <!-- isCollapse ：收缩属性   -->
  <el-menu :default-openeds="opens"
           :router="true"
           background-color="rgb(30, 25, 45)"
           text-color="#fff"
           :collapse-transition="true"
           style="height: 700px;"
           router
           >

    <div style="height: 60px; line-height: 60px;text-align: center; float: bottom;">
      <img src="../assets/logo.png" alt="" style="width: 20px; position: relative; top: 5px; right: 5px">
      <b style="color: white">后台管理系统</b>
    </div>
    <div v-for="item in menus" :key="item.id ">
      <div v-if="item.menuPath">
        <el-menu-item :index="item.menuPath">
            <i :class="item.icon"></i>
            <span slot="title">{{item.menuName}}</span>
        </el-menu-item>
      </div>
      <div v-else>
<!-- 一级菜单上，-->
        <el-submenu :index="item.id + ''">
          <template slot="title">
            <i :class="item.icon"></i>
            <span slot="title">{{item.menuName}}</span>
          </template>
<!--          二级菜单，遍历一级菜单的子路由-->
          <div v-for="subItem in item.children" :key="subItem.id ">
            <el-menu-item :index="subItem.menuPath">
              <i :class="subItem.icon"></i>
              <span slot="title">{{subItem.menuName}}</span>
            </el-menu-item>
          </div>
        </el-submenu>
      </div>
    </div>
<!--    <el-menu-item index="/">
      <template slot="title">
        <i class="el-icon-s-home"></i>
        <span slot="title">主页</span>
      </template>
    </el-menu-item>
    <el-submenu index="2">
      <template slot="title">
        <i class="el-icon-s-goods"></i>
        <span slot="title">系统管理</span>
      </template>
      <el-menu-item index="/user">
        <i class="el-icon-user"></i>
        <span slot="title">用户管理</span>
      </el-menu-item>
      <el-menu-item index="/role">
        <i class="el-icon-s-custom"></i>
        <span slot="title">角色管理</span>
      </el-menu-item>
      <el-menu-item index="/file">
        <i class="el-icon-folder-opened"></i>
        <span slot="title">文件管理</span>
      </el-menu-item>
      <el-menu-item index="/menu">
        <i class="el-icon-menu"></i>
        <span slot="title">菜单管理</span>
      </el-menu-item>
    </el-submenu>
    <el-submenu index="3">
      <template slot="title">
        <i class="el-icon-s-goods"></i>
        <span slot="title">字典</span>
      </template>
      <el-menu-item index="/dict">
        <i class="el-icon-user"></i>
        <span slot="title">字典录入</span>
      </el-menu-item>
    </el-submenu>-->
  </el-menu>
</template>

<script>
export default {
  name: "Aside",
  props: {
    /*初始化，接收manger中传入的menus*/
  },
  methods:{
    /*可在el-menus标签头中添加@Select方法绑定该方法重新显示生效
    handleSelect(index){
      //结合@select擦看index地址
      console.log(index)
      //定义的所有路由消息打印
      console.log(this.$router.options.routes)
    }*/
  },
  data(){
    return{
      menus: localStorage.getItem("menus")? JSON.parse(localStorage.getItem("menus")) : [],
      /*展开默认值传menus的遍历id*/
      opens: localStorage.getItem("menus")? JSON.parse(localStorage.getItem("menus")).map(v => v.id + '') : []
    }
  },


}
</script>

<style scoped>

</style>